#!/bin/sh

uci -q batch <<-EOF >/dev/null
	delete firewall.pptpd
	set firewall.pptpd=include
	set firewall.pptpd.type=script
	set firewall.pptpd.path=/etc/pptpd.include
	set firewall.pptpd.reload=1
	delete firewall.pptp
  add firewall rule 
  rename firewall.@rule[-1]="pptp"
  set firewall.@rule[-1].name="pptp"
  set firewall.@rule[-1].target="ACCEPT"
  set firewall.@rule[-1].src="wan"
  set firewall.@rule[-1].proto="tcp"
  set firewall.@rule[-1].dest_port="1723"
  delete firewall.gre
  add firewall rule 
  rename firewall.@rule[-1]="gre"
  set firewall.@rule[-1].name="gre"
  set firewall.@rule[-1].target="ACCEPT"
  set firewall.@rule[-1].src="wan"
  set firewall.@rule[-1].proto="47"
  commit firewall
EOF

uci -q batch <<-EOF >/dev/null
	delete ucitrack.@pptpd[-1]
	add ucitrack pptpd
	set ucitrack.@pptpd[-1].init=pptpd
	commit ucitrack
EOF

/etc/init.d/pptpd enable && /etc/init.d/pptpd restart

rm -f /tmp/luci-indexcache
exit 0
